﻿using System;
using System.Threading;
using System.Windows.Forms;
using System.Drawing;

namespace PPHandler
{
    class Util
    {

        public static Window GetPPTableWindow(int tnr){
            Windows windows = new Windows();
            int left = tnr % 2 == 0 ? 0 : 640;
            int top = tnr < 2 ? 0 : 470;
            foreach (Window window in windows.lstWindows){
                if (window.title.Contains("FL"))
                {
                    if (left == window.getUpperLeftX()
                        && top == window.getUpperLeftY())
                    {
                        return window;
                    }
                }
            }
            return null;
        }

        /// <summary>
        /// MakeLParam Macro
        /// </summary>
        public static int MakeLParam(int LoWord, int HiWord)
        {
            return ((HiWord << 16) | (LoWord & 0xffff));
        }


        public static void leftClick(int x, int y)
        {
            Cursor.Position = new Point(x, y);
            User32.mouse_event((uint)MouseEvents.MOUSEEVENTF_LEFTDOWN | (uint)MouseEvents.MOUSEEVENTF_LEFTUP, (uint)Cursor.Position.X, (uint)Cursor.Position.Y, 0, 0);
        }

    }

}
